<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>订单列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
    <style>
        .layui-hide{  /*最后的pic为字段的field*/
            height: 100%;
            max-width: 100%;
        }
        .layui-table-cell{
            height:auto !important;
        }
    </style>
</head>
<body>
<div id="aaa"></div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">订单列表</div>
                <div class="layui-card-body">
                    <div class="layui-form-item layui-form">

                        {if !empty($res)}
                        <div class="layui-inline">
                            <label class="layui-form-label">订单编号</label>
                            <div class="layui-input-block">
                                <select name="order_sn" lay-verify="" lay-search id="order_sn">
                                    <option value="">请选择</option>
                                    {foreach $res as $k=>$v}
                                    <option value="{$v['order_sn']}">{$v['order_sn']}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">是否支付</label>
                            <div class="layui-input-block">
                                <select name="order_status" lay-filter="aihao" id="order_status">
                                    <option value=""></option>
                                    <option value="0">未支付</option>
                                    <option value="1">已支付</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">下单时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="test6" placeholder="  ">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-btn-group test-table-operate-btn">
                                <button class="layui-btn" data-type="searchUserButton">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>
                        {/if}
                    </div>
                    <table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate">
                    </table>
                    <script type="text/html" id="test-table-operate-barDemo">

                    </script>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="contentShow" style="display:none;padding: 30px;">
    <p id="consultation"></p>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>

<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //日期范围
        laydate.render({
            elem: '#test6'
            ,range: true
        });
    });
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','table','laydate','set'], function(){
        $ = layui.jquery;
        var table = layui.table
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,form = layui.form;

        table.render({
            elem: '#test-table-operate'
            ,url: "{:url('Vote/order')}"
            ,height: 'full-155'
            ,cols: [[
                {field:'order_id',align:'center', title: 'ID'}
                ,{field:'order_sn',align:'center',title: '订单编号'}
                ,{field:'nickname',align:'center',title: '下订单昵称'}
                ,{field:'shop_name',align:'center',title: '商品名称'}

                ,{field:'vote_num',align:'center',title: '票数'}
                ,{field:'order_price', align:'center', title: '支付金额'}
                ,{field:'order_status',align:"center",title: '是否支付',templet:function(d){
                        if (d.order_status == 1){
                            return "已支付";
                        }else if(d.order_status == 0){
                            return "未支付";
                        }
                    }}
                ,{field:'pay_type',align:"center",title: '支付方式',templet:function(d){
                        if (d.pay_type == 1){
                            return "支付宝";
                        }else if(d.pay_type ==2){
                            return "微信";
                        }else if(d.pay_type ==0){
                            return "未支付";
                        }
                    }}
                ,{field:'create_time',align:'center',title: '订单时间'}
            ]]
            ,page:true
            ,limit:20
        });

        form.render(null,'component-form-group');

        laydate.render({
            elem: '#search_time'
        });

        //监听工具条
        table.on('tool(test-table-operate)', function(obj){
            var data = obj.data;

        });

        var $ = layui.$, active = {
            searchUserButton:function(){
                var order_sn  = $('#order_sn').val();
                var is_pass = $('#is_pass').val();
                var order_status = $("#order_status").val();
                var create_time = $('#test6').val();
                table.reload('test-table-operate', {
                    where: {
                        order_sn:order_sn,
                        order_status:order_status,
                        create_time:create_time
                    }
                    ,page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
                //return false;
            }
        };
        //绑定点击事件
        $('.test-table-operate-btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>


</body>
</html>